package com.baize.motionlayoutdemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.transition.TransitionManager

/**
 * 过渡动画一：使用TransitionManager#beginDelayedTransition 实现简单过渡动画
 */
class TransitionActivity : AppCompatActivity() {

  lateinit var root: ViewGroup

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_transition)
    root = findViewById(R.id.root)
  }

  fun onClick(v: View) {
    TransitionManager.beginDelayedTransition(root)
    (v.layoutParams as FrameLayout.LayoutParams).gravity = Gravity.CENTER
    v.requestLayout()
  }
}